#!/bin/bash
cd "$(dirname "$0")"

MODE=$1

if [[ "$MODE" == "--dev" || "$MODE" == "-d" || "$MODE" == "dev" || "$MODE" == "development" ]]; then
  lsof -ti:8000 | xargs kill -9 2>/dev/null
  nohup uvicorn server.main:app --reload --port 8000 > /dev/null 2>&1 &
  cd web
  nohup pnpm run dev > /dev/null 2>&1 &
else
  nohup uvicorn server.main:app --port 8000 > /dev/null 2>&1 &
  cd web
  nohup pnpm start > /dev/null 2>&1 &
fi
